/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package lichbaogiang;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */
public class InsertTeacher extends javax.swing.JPanel {

    //-----------------
    String masoGV, tenGV, soDT, email, bomon;
    int namBD, hsChuyenMon, hsnckh;
    float hsThamNien, diem;
    /**
     * Creates new form InsertTeacher
     */
    public InsertTeacher() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbmasoGV = new javax.swing.JLabel();
        txtmasoGV = new javax.swing.JTextField();
        lbtenGV = new javax.swing.JLabel();
        txttenGV = new javax.swing.JTextField();
        lbchuyenmon = new javax.swing.JLabel();
        cbchuyenmon = new javax.swing.JComboBox();
        lbEmail = new javax.swing.JLabel();
        lbsoDT = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        txtsoDT = new javax.swing.JTextField();
        lbnamBD = new javax.swing.JLabel();
        txtnamBD = new javax.swing.JTextField();
        lbhsThamNien = new javax.swing.JLabel();
        txthsThamNien = new javax.swing.JTextField();
        lbsChuyenMon = new javax.swing.JLabel();
        txthsChuyenMon = new javax.swing.JTextField();
        lbhsnckh = new javax.swing.JLabel();
        txthsnckh = new javax.swing.JTextField();
        btnAdd = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        lbdiem = new javax.swing.JLabel();
        txtdiem = new javax.swing.JTextField();

        setBackground(new java.awt.Color(255, 255, 255));

        lbmasoGV.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbmasoGV.setText("Mã Số Giảng Viên");

        lbtenGV.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbtenGV.setText("Tên Giảng Viên");

        lbchuyenmon.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbchuyenmon.setText("Chuyên Môn");

        cbchuyenmon.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3" }));

        lbEmail.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbEmail.setText("Email");

        lbsoDT.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbsoDT.setText("Số ĐT");

        lbnamBD.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbnamBD.setText("Năm Bắt Đầu");

        lbhsThamNien.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbhsThamNien.setText("HS Thâm Niên");

        lbsChuyenMon.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbsChuyenMon.setText("HS Chuyên Môn");

        lbhsnckh.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbhsnckh.setText("HS NCKH");

        btnAdd.setBackground(new java.awt.Color(0, 153, 0));
        btnAdd.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnAdd.setText("Thêm");
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddActionPerformed(evt);
            }
        });

        jLabel1.setBackground(new java.awt.Color(204, 0, 0));
        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(204, 0, 0));
        jLabel1.setText("DANH SÁCH GIẢNG VIÊN");

        lbdiem.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbdiem.setText("Điểm");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbmasoGV)
                    .addComponent(lbtenGV)
                    .addComponent(lbchuyenmon)
                    .addComponent(lbsChuyenMon))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(cbchuyenmon, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lbnamBD)
                        .addGap(18, 18, 18))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txtmasoGV)
                                .addComponent(txttenGV, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(txthsChuyenMon, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(67, 67, 67)
                                .addComponent(lbhsnckh)
                                .addGap(18, 18, 18)
                                .addComponent(txthsnckh, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(52, 52, 52)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbEmail)
                            .addComponent(lbsoDT))
                        .addGap(35, 35, 35)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtEmail)
                            .addComponent(txtsoDT, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(lbdiem)
                                .addGap(18, 18, 18)
                                .addComponent(txtdiem, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnAdd))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(txtnamBD, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 80, Short.MAX_VALUE)
                                .addComponent(lbhsThamNien)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txthsThamNien, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(8, 8, 8)))
                .addContainerGap(47, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(299, 299, 299)
                .addComponent(jLabel1)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbmasoGV)
                    .addComponent(txtmasoGV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbEmail)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbtenGV)
                    .addComponent(txttenGV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbsoDT)
                    .addComponent(txtsoDT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbchuyenmon)
                    .addComponent(cbchuyenmon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbnamBD)
                    .addComponent(txtnamBD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbhsThamNien)
                    .addComponent(txthsThamNien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbsChuyenMon)
                    .addComponent(txthsChuyenMon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbhsnckh)
                    .addComponent(txthsnckh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAdd)
                    .addComponent(lbdiem)
                    .addComponent(txtdiem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
        
        masoGV = txtmasoGV.getText();
        tenGV = txttenGV.getText();
        soDT = txtsoDT.getText();
        email = txtEmail.getText();
        bomon = (String) cbchuyenmon.getSelectedItem();
        namBD = Integer.parseInt(txtnamBD.getText());
        hsChuyenMon = Integer.parseInt(txthsChuyenMon.getText());
        hsnckh = Integer.parseInt(txthsnckh.getText());
        hsThamNien = Float.parseFloat(txthsThamNien.getText());
        diem = Float.parseFloat(txtdiem.getText());
        if(JOptionPane.showConfirmDialog(this,"Bạn có chắc chắn thêm?","Yes/No!",JOptionPane.YES_NO_OPTION) == 0) 
        {
            String sql = "insert into GiangVien1 values('"+masoGV+"','"+tenGV+"','"+soDT+"','"+email+"','"
                    +namBD+"','"+hsThamNien+"','"+hsChuyenMon+"','"+hsnckh+"','"+diem+"','"+bomon+"')";
            try{
                String url = "jdbc:odbc:CNPM";
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection conn = DriverManager.getConnection(url);
                Statement stmt = conn.createStatement();
                stmt.execute(sql);
            }
            catch(Exception e){}
            JOptionPane.showConfirmDialog(this, "Thêm thành công, Nhấn Cập Nhật để xem!", "Thành công!", JOptionPane.DEFAULT_OPTION);
        }
    }//GEN-LAST:event_btnAddActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdd;
    private javax.swing.JComboBox cbchuyenmon;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel lbEmail;
    private javax.swing.JLabel lbchuyenmon;
    private javax.swing.JLabel lbdiem;
    private javax.swing.JLabel lbhsThamNien;
    private javax.swing.JLabel lbhsnckh;
    private javax.swing.JLabel lbmasoGV;
    private javax.swing.JLabel lbnamBD;
    private javax.swing.JLabel lbsChuyenMon;
    private javax.swing.JLabel lbsoDT;
    private javax.swing.JLabel lbtenGV;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtdiem;
    private javax.swing.JTextField txthsChuyenMon;
    private javax.swing.JTextField txthsThamNien;
    private javax.swing.JTextField txthsnckh;
    private javax.swing.JTextField txtmasoGV;
    private javax.swing.JTextField txtnamBD;
    private javax.swing.JTextField txtsoDT;
    private javax.swing.JTextField txttenGV;
    // End of variables declaration//GEN-END:variables
}
